package dao

import (
	"github.com/PhlexTheCharr/gofurry-cloud-service/apps/openlist/util/models"
	"github.com/PhlexTheCharr/gofurry-cloud-service/common"
	"github.com/PhlexTheCharr/gofurry-cloud-service/common/abstract"
)

var newUtilDao = new(UtilDao)

func init() {
	newUtilDao.Init()
}

type UtilDao struct{ abstract.Dao }

func GetUtilDao() *UtilDao { return newUtilDao }

// 按 id 序返回指定的金句
func (dao UtilDao) GetSayingByOrder(index int) (*models.OlSaying, common.GFError) {
	var res models.OlSaying
	db := dao.Gm.Table("ol_saying").Order("id")
	db.Offset(index).Limit(1)
	db.First(&res)
	if err := db.Error; err != nil {
		return nil, common.NewDaoError(err.Error())
	}
	return &res, nil
}
